/*    */ package com.zimbra.cs.redolog.op;
/*    */ 
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.MailboxOperation;
/*    */ import com.zimbra.cs.redolog.RedoLogInput;
/*    */ import com.zimbra.cs.redolog.RedoLogOutput;
/*    */ import com.zimbra.cs.redolog.Version;
/*    */ import com.zimbra.cs.util.AccountUtil;
/*    */ import java.io.IOException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class RenameMailbox
/*    */   extends RedoableOp
/*    */ {
/*    */   private String mNewName;
/*    */   private String mOldName;
/*    */   
/*    */   public RenameMailbox()
/*    */   {
/* 35 */     super(MailboxOperation.RenameMailbox);
/*    */   }
/*    */   
/*    */   public RenameMailbox(int mailboxId, String oldName, String newName) {
/* 39 */     this();
/* 40 */     setMailboxId(mailboxId);
/* 41 */     this.mNewName = newName;
/*    */   }
/*    */   
/*    */   protected void serializeData(RedoLogOutput out) throws IOException {
/* 45 */     out.writeUTF(this.mNewName);
/* 46 */     if (getVersion().atLeast(1, 25))
/* 47 */       out.writeUTF(this.mOldName);
/*    */   }
/*    */   
/*    */   protected void deserializeData(RedoLogInput in) throws IOException {
/* 51 */     this.mNewName = in.readUTF();
/* 52 */     if (getVersion().atLeast(1, 25))
/* 53 */       this.mOldName = in.readUTF();
/*    */   }
/*    */   
/*    */   protected String getPrintableData() {
/* 57 */     return "newName=" + this.mNewName + " oldName=" + this.mOldName;
/*    */   }
/*    */   
/*    */   public void redo() throws Exception {
/* 61 */     Mailbox mbox = MailboxManager.getInstance().getMailboxById(getMailboxId());
/*    */     
/*    */ 
/* 64 */     if ((this.mNewName != null) && (AccountUtil.addressMatchesAccount(mbox.getAccount(), this.mOldName))) {
/* 65 */       mbox.renameMailbox(this.mOldName, this.mNewName);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/RenameMailbox.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */